package demoMod.stsconsole.rooms;

import demoMod.stsconsole.dungeons.AbstractDungeon;
import demoMod.stsconsole.map.MapNode;

import java.util.List;

public class DungeonTransitionRoom extends AbstractRoom {
    @Override
    public void onPlayerEntry() {
        super.onPlayerEntry();
        this.phase = RoomPhase.COMPLETED;
        AbstractDungeon nextDungeon = AbstractDungeon.getDungeon((float)(Math.floor(AbstractDungeon.currDungeon.getActNum()) + 1));
        nextDungeon.passedDungeons.addAll(AbstractDungeon.currDungeon.passedDungeons);
        nextDungeon.passedDungeons.add(AbstractDungeon.currDungeon.dungeonId);
        nextDungeon.map = nextDungeon.generateMap();
        List<List<MapNode>> nodes = nextDungeon.map.getNodes();
        nextDungeon.currMapNode = new MapNode();
        for (MapNode node : nodes.get(0)) {
            if (node.next.size() > 0) {
                nextDungeon.currMapNode.next.add(node);
                node.prev.add(nextDungeon.currMapNode);
            }
        }
        nextDungeon.currMapNode.room.onPlayerEntry();
        AbstractDungeon.currDungeon = nextDungeon;
        System.out.println("Next dungeon is:" + nextDungeon.dungeonId);
    }

    @Override
    public String getRoomSymbol() {
        return "D";
    }
}
